{% extends "base.html" %}
{% block title %}Mgroups{% endblock %}
{% block content %}
<!--atsystem-->
                <!--/span-->

                <div class="span9" id="content">

                    <div class="row-fluid">
                      <!--  <div class="alert alert-success">
                                                        <button type="button" class="close" data-dismiss="alert">&times;</button>
                            <h4>Success</h4>
                                The operation completed successfully</div>-->
                                <div class="navbar">
                                <div class="navbar-inner">
                                        <ul class="breadcrumb">
                                            <i class="icon-chevron-left hide-sidebar"><a href='#' title="Hide Sidebar" rel='tooltip'>&nbsp;</a></i>
                                            <i class="icon-chevron-right show-sidebar" style="display:none;"><a href='#' title="Show Sidebar" rel='tooltip'>&nbsp;</a></i>
                                            <li>
                                                <a href="/admin/">Dashboard</a> <span class="divider">/</span>
                                            </li>
                                            <li>
                                                <a href="/admin/mgroups/">Mgroups</a> <span class="divider">/</span> 
                                            </li>
						<!--
                                            <li class="active">Tools</li>-->
                                        </ul>
                                </div>
                                </div>
                        </div>




                     <div class="row-fluid">
                        <!-- block -->
                        <div class="block">
                            <div class="navbar navbar-inner block-header">
                                <div class="muted pull-left">Mgroups List</div>
                            </div>
                            <div class="block-content collapse in">
                                <div class="span12">
                                                                     <div class="table-toolbar">
                                      <div class="btn-group">
                                         <a href="/admin/mgroups/mgroupadd/"><button class="btn btn-success">Mgroup Add <i class="icon-plus icon-white"></i></button></a>
                                      </div>
<font size="5"><b>|</b></font>
										<div class="btn-group">
										  <button class="btn btn-primary">Action</button>
										  <button data-toggle="dropdown" class="btn btn-primary dropdown-toggle"><span class="caret"></span></button>
										  <ul class="dropdown-menu">
											<li><a href="#"  id = "action1" onclick="chk()"  value="action1">Host Status</a></li>
											<li><a href="#"  id = "action2" onclick="chk2()"  value="action2">File Copy</a></li>
											<li><a href="#"  id = "action3" onclick="chk3()"  value="action3">Exec Cmd</a></li>
											<li><a href="#"  id = "action4" onclick="chk4()"  value="action4">Install Software</a></li>
											<li><a href="#">nothing</a></li>
											<li><a href="#">nothing</a></li>
											<li class="divider"></li>
											<li><a href="#">nothing</a></li>
										  </ul>
										</div>
                                   </div>
  
  		                  <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
										<thead>
											<tr>
												<th><input class="uniform_on" type="checkbox" id="optionsCheckbox" value="option1"></th>
												<th>Minion ID</th>
												<th>Comment</th>
												<th>Detail</th>
												<th>Operation</th>
											</tr>
										</thead>
										<tbody>
										{% for mgroup in mgroups %}
											<tr class="gradeC">
												<td><input name = "checkbox" class="uniform_on" type="checkbox"  value="{{mgroup.mg_name}}"></td>
												<td><B><p  style="font-size:15px">{{mgroup.mg_name}}</p></B></td>
												<td>{{mgroup.comment}}</td>
												<td><a  href="/admin/mgroups/mgprofile/{{mgroup.mg_name}}" >Detail&Edit</a>&nbsp;</td>
										<!--		<td><a id = "delbtn" href="#" onclick = "getdata()" class="btn  btn-primary btn-mini"><i class="icon-pencil icon-white"></i>Detail</a>&nbsp;</td>-->
												<td><a id = "delbtn" href="/admin/mgroups/del_mg/{{mgroup.mg_name}}" onclick = "getdata()" class="btn  btn-danger btn-mini"><i class="icon-remove icon-white"></i>Delete</a>&nbsp;</td>
											</tr>
										{% endfor %}

										</tbody>
									</table>
                                </div>
                            </div>
                        </div>
                        <!-- /block -->
                    </div>

       
                </div>

            </div>
<script LANGUAGE="javascript">
  $("#optionsCheckbox").click(function() {
    $("input[name='checkbox']").prop("checked", this.checked);
  });
  $("input[name='checkbox']").click(function() {
    var $subs = $("input[name='checkbox']");
    $("#optionsCheckbox").prop("checked" , $subs.length == $subs.filter(":checked").length ? true :false);
  });
</script>


<script "text/javascript">
function chk(){
var obj=document.getElementsByName("checkbox");
var array1=new Array();
for(var i=0;i<obj.length;i++)
{
if(obj[i].checked)
{
array1.push(obj[i].value);
}
}

if(array1 == ""){
alert("Please choice a host least!!");
}
else{
array1.push('_mgroup');
$.post('/admin/host_exec/',
{
'arraydata':JSON.stringify(array1)
},

function(data){
alert(data);
});
}
}
///////////////////////////////////////////////////////////////////////////

function chk2(){
var obj=document.getElementsByName("checkbox");
var array2=new Array();
for(var i=0;i<obj.length;i++)
{
if(obj[i].checked)
{
array2.push(obj[i].value);
}
}
if(array2 == ""){

alert("Please choice a host least!!");
}
else
array2.push('_mgroup')
{
window.open('/admin/file_copy/?cpinfo='+array2,'newwindow','width=1100,height=800,location=no,scrollbars=yes,status=yes');
}
}

/////////////////////////////////////////////////////////////////////////////////


function chk3(){
var obj=document.getElementsByName("checkbox");
var array3=new Array();
for(var i=0;i<obj.length;i++)
{
if(obj[i].checked)
{
array3.push(obj[i].value);
}
}
if(array3 == ""){

alert("Please choice a host least!!");
}
else
array3.push('_mgroup')
{
window.open('/admin/execmd/?exeinfo='+array3,'newwindow','width=1100,height=800,location=no,scrollbars=yes,status=yes');
}
}





/////////////////////////////////////////////////////////////////////////////////


function chk4(){
var obj=document.getElementsByName("checkbox");
var array4=new Array();
for(var i=0;i<obj.length;i++)
{
if(obj[i].checked)
{
array4.push(obj[i].value);
}
}
if(array4 == ""){

alert("Please choice a host least!!");
}
else
array4.push('_mgroup')
{
window.open('/admin/software/?info='+array4,'newwindow','width=1100,height=800,location=no,scrollbars=yes,status=yes');
}
}


//////////////////////////////////////////////////////////

function getdata(){
alert("Developing......");

}


</script>
{% endblock %}
